﻿using System;
using System.Net.Mail;
using Messaging.Config;
using System.Net; 

namespace Messaging.Senders
{
    internal class MessageSender : IMessageSender
    {
        public void Send(MailMessage message)
        {
            SmtpClient client = new SmtpClient(SMTPConfig.SmtpServer, SMTPConfig.SmtpPort);
            client.EnableSsl = SMTPConfig.SmtpEnableSSL;
            client.UseDefaultCredentials = SMTPConfig.SmtpUseDefaultCredentials;
            if (!SMTPConfig.SmtpUseDefaultCredentials)
                client.Credentials = new NetworkCredential(SMTPConfig.SmtpUserName, SMTPConfig.SmtpPassword);
            client.Send(message);
        }
    }
}
